package eg.com.itiga.ui.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


import eg.com.itiga.business.company.CompanyService;
import eg.com.itiga.business.factory.BusinessFactory;
import eg.com.itiga.domain.Company;
import eg.com.itiga.ui.beans.ManageCompanyActionForm;

public class DeactivateCompanyAction extends org.apache.struts.action.Action {
    


    
    public DeactivateCompanyAction() {
    }
    
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        
    	
    	//write hibernate deactivate code
    	
    	CompanyService companyService = BusinessFactory.createCompanyService();
    	
    	ManageCompanyActionForm frm = (ManageCompanyActionForm)form;
    	
    	Company company = (Company)companyService.find(Company.class,frm.getSelectedCompany());
    	if(company != null)
    	{
    		company.setCIsRegistered(false);
    		//ma3lesh, hena hy3mel saveOrUpdate.....
        	companyService.add(company);
    	}
    	
    	
    	
    	
    	
    	
    	
        return mapping.findForward("companydeactivated");
    }

}